app.controller('brandController', function ($scope, $controller, brandService) {

    $controller('baseController', {$scope: $scope});//继承

    $scope.searchEntity = {};
    $scope.deleteBrand = function () {
        brandService.deleteBrand($scope.selectIds).success(function (response) {
            if (response.success) {  //删除成功后
                $scope.reloadList();
                $scope.selectIds = [];
            } else {
                alert(response.message);
            }
        })
    }
    $scope.saveBrand = function () {
        brandService.saveBrand($scope.entity).success(function (response) {
            if (response.success) {
                $scope.reloadList();
            } else {
                alert(response.message);
            }
        })
    },
        $scope.findOne = function (id) {
            brandService.findOne(id).success(function (response) {
                $scope.entity = response;
            });
        },
        $scope.findAll = function () {
            brandService.findAll().success(function (response) {
                $scope.list = response;
            })
        }
    $scope.search = function (page, rows) {
        brandService.search(page, rows, $scope.searchEntity).success(function (response) {
            /**
             * 把pageResult里面的list拿出来，赋给页面的list了
             * 再把里面的总记录数赋给分页组件了
             */
            $scope.list = response.rows;
            $scope.paginationConf.totalItems = response.total;//更新总记录数
        })
    }
    //有重新写了一个search方法，和这个几乎一样的，就是给后台传递的时候
    $scope.findPage = function (page, rows) {
        brandService.findPage(page, rows).success(function (response) {
            /**
             * 把pageResult里面的list拿出来，赋给页面的list了
             * 再把里面的总记录数赋给分页组件了
             */
            $scope.list = response.rows;
            $scope.paginationConf.totalItems = response.total;//更新总记录数
        })
    }

});